October 23, 2014

Outline

  • Conference impressions
    • Tutorials
    • Talks
  • Code snippets
    • Rcpp
  • Outlook

poster.png

Conference impressions

Tutorials

Tuesday

  • Rcpp and C++
  • ggplot2
  • Using spatial data
  • Classification with individual and ensemble trees
  • Interactive web graphics with R and googleVis
  • Cloud computing
morebooks.jpg books.jpg books1.jpg

Tutorials

ggplot2

  • written by Hadley Wickham
  • implementation of the grammar of graphics
  • combines the advantages of both base and lattice graphics
ggplot2.jpg

Conference

Wednesday to Friday

talk.jpg peopleout.jpg

Conference

Talks

  • Invited talks
    • Duncan Murdoch
    • Hadley Wickham
    • Steve Scott
  • Contributed talks
    • useR! Focus Sessions
    • useR! Lightning Talks
    • useR! Kaleidoscope
talk.jpg talkco.jpg

Conference

Poster sessions

  • Bioinformatics
  • Econometrics
  • Ecological modeling
  • Marketing
  • Public policy
  • Social sciences
  • Statistics
posterse.jpg poster2.jpg

Conference

Social life

tapas.jpg

tapass.jpg tapasco.jpg

Code snippets

Rcpp

  • written by Dirk Eddelbuettel and Romain François
  • seamless R and C++ integration
    • supports many R data types
    • provides typical R functions and C++ classes
seamless.png

Why use C++ integration in R?

Sometimes, R code is just not fast enough…

impatience

  • Loops that cannot be vectorized because subsequent iterations depend on previous ones
# Count number of remaining samples (iterations)

nLeft <- 3
for (i in 1:3) {
  cat("Processing sample ", i, ". ", sep = "")

  ## (some sample-related operations)
  
  nLeft <- nLeft - 1
  cat(nLeft, "samples left ...\n")
}
## Processing sample 1. 2 samples left ...
## Processing sample 2. 1 samples left ...
## Processing sample 3. 0 samples left ...

  • Recursive function calls
# Fibonacci sequence

fibonacci <- function(x) {
  if (x < 2) {
    return(x)
  } else {
    return(fibonacci(x-1) + fibonacci(x-2))
  }
}

sapply(1:10, fibonacci)
##  [1]  1  1  2  3  5  8 13 21 34 55

An example: the sum function


  • Base-R approach
  • x <- 1:10000
    
    sum(x)
    ## [1] 50005000

    An example: the sum function


  • Custom R approach
  • sumR <- function(x) {
      
      total <- 0
      for (i in 1:length(x)) {
        total <- total + x[i]
      }
      
      return(total)
    }
    
    sumR(x)
    ## [1] 50005000

    An example: the sum function


  • Rcpp approach
  • library(Rcpp)
    
    cppFunction('double sumC(NumericVector x) {
                
      int n = x.size();
      double total = 0;
      
      for(int i = 0; i < n; ++i) {
        total += x[i];
      }
      
      return total;
    }')
    
    sumC(x)
    ## [1] 50005000

    An example: the sum function


  • Speed test
  • library(microbenchmark)
    
    microbenchmark(sum(x), sumR(x), sumC(x), times = 1000L)
    ## Unit: microseconds
    ##     expr      min        lq       mean    median       uq       max neval
    ##   sum(x)    9.637    9.8745   12.61476   11.9305   14.818   236.301  1000
    ##  sumR(x) 3700.914 3960.5945 4422.09303 4178.9590 4723.615 42668.660  1000
    ##  sumC(x)   20.961   22.2015   32.14437   32.6745   38.002   185.743  1000

    Outlook

    user2015

    With invited talks by

    • Thomas Lumley (R Core Team)
    • Adrian Baddeley (spatstat)
    • Romain François (Rcpp)

    (see http://user2015.math.aau.dk/)

    Side note

    group_image Thank you for your attention!